import { Controller, Get, Query } from '@nestjs/common';
import { VideoService } from './video.service';
import { Post, UseInterceptors, UploadedFile, Body } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';

@Controller('video')
export class VideoController {
  constructor(private readonly videoService: VideoService) {}

  //上传视频
  @Post('upload')
  @UseInterceptors(FileInterceptor('file'))
  async upload(@UploadedFile() file, @Body() body: string) {
    console.log('Uploaded file:', file);
    console.log('body:', body);
    
    // 现在您可以在这里执行您的上传逻辑
    await this.videoService.upload(file, body);
  }

  //获取视频列表或者通过id获取对应视频

  @Get('list')
  async list(@Query() query: any) {
    return await this.videoService.list(query);
  }
}
